package com.example.big_job.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.big_job.R;

import java.util.List;

public class MainAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{

    private Context context;
    private List<Integer> mDatas;
    //private AdapterView.OnItemClickListener listener;

    public MainAdapter(Context context, List<Integer> mDatas) {
        this.context = context;
        this.mDatas = mDatas;
    }


    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view;
        view= LayoutInflater.from(context).inflate(R.layout.item_main1, parent, false);
        return new mainViewHolder(view);
    }


    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        mainViewHolder mainviewHolder=(MainAdapter.mainViewHolder) holder;
        if (position==7){
            mainviewHolder.dixian.setText("——————————我是有底线的——————————");
        }if (position==1){
            mainviewHolder.dixian.setText("");
        }

        mainviewHolder.imageView.setImageResource(mDatas.get(position));
    }

    @Override
    public int getItemCount() {
        return mDatas.size();

    }
    public class mainViewHolder extends RecyclerView.ViewHolder{
        private ImageView imageView;
        private TextView dixian;

        public mainViewHolder(@NonNull View itemView) {
            super(itemView);
            imageView=itemView.findViewById(R.id.im0);
            dixian=itemView.findViewById(R.id.dixian);
        }
    }
}
